<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn"  uri="http://java.sun.com/jsp/jstl/functions"  %>
<c:set var="currentTime" value="<%=System.currentTimeMillis()%>"></c:set>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>CMS主页面</title>
 
	
	<link rel="stylesheet" href="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/css/bootstrap.min.css">
	<script src="https://cdn.static.runoob.com/libs/jquery/2.1.1/jquery.min.js"></script>
	<script src="https://cdn.static.runoob.com/libs/bootstrap/3.3.7/js/bootstrap.min.js"></script>

  </head>
  
  <body>
  
  <!-- 页面导航条 -->
    <nav class="navbar navbar-default">
	<div class="container">
	<div class="navbar-header">
		<span class="navbar-brand">CMS菜单页</span>
	</div>
	<div>
		<ul class="nav navbar-nav navbar-inverse navbar-left">
            <li ><a href="javascript:void(0)">
                最新文章</a>
            </li>
            <li><a href="javascript:void(0)">
                明星公司</a>
            </li>
            <li><a href="javascript:void(0)">
                行业新闻</a>
            </li>
        </ul>
    </div>
   </div>
   </nav>
   
   <!-- 文章列表显示 -->
   <div>
       <ul class="nav nav-list">
       <c:forEach items="${list }" var="article" varStatus="var">
          <li  class="divider">
              <div class="container-fluid">
              <div class="row-fluid">
              
              <aside>
              <label  class="pull-left col-sm-1">${var.index+1 }</label>
              <a><img class="pull-left col-sm-3" src="<%=basePath%>${article.article_img }"/></a>
              </aside>
              <div >
              <article>
              <h1><a href="<%=basePath%>/article/article_details?id=${article.id }">${article.article_title }</a></h1>
              <section>
             <%-- ${fn:substring(article.article_content,0,10) } --%>
              <c:choose> 
			     <c:when test="${fn:length(article.article_content) > 100}"> 
			      <c:out value="${fn:substring(article.article_content,0,100) }......" /> 
			     </c:when> 
			     <c:otherwise> 
			      <c:out value="${article.article_content}" /> 
			     </c:otherwise>
			  </c:choose>
              </section>
              </article>
              <span>${article.article_author }:
              <fmt:parseDate var="create_d" value="${article.create_date}" pattern="yyyy-MM-dd HH:mm:ss"/>
              <c:if test="${((currentTime-create_d.time)/1000/60/60)>=1}">                                      
				  <fmt:formatNumber value="${((currentTime-create_d.time)/1000/60/60)}"/> 小时前
			  </c:if> 
			  <c:if test="${((currentTime-create_d.time)/1000/60/60)<1}"> 
    			  <fmt:formatNumber value="${((currentTime-create_d.time)/1000/60)}" /> 分钟前
			  </c:if>
              </span>
              <span>&nbsp;&nbsp;${article.article_category }</span> 
              </div>
              </div>
              </div>
              <%-- <span><a href="<%=basePath%>/article/add_edit?id=${article.id }">编辑</a></span> --%>         
          </li>
          <li class="divider"></li>  
          </c:forEach>
       </ul>
       <button><a href="<%=basePath%>/article/add_edit">新增</a></button>
   </div>
   
  </body>
</html>
